package thirdPart;

import java.util.ArrayList;
import java.util.List;

public class ThreadLocalTest2 {

    private static final ThreadLocal<List<LoTest>> deadShuiQiuThreadLocal = ThreadLocal.withInitial(ArrayList::new);

    public static void main(String[] args) {
        ThreadLocalTest2 threadLocalTest2 = new ThreadLocalTest2();
        threadLocalTest2.method1();
        threadLocalTest2.method2();
    }

    public void method1() {
        deadShuiQiuThreadLocal.get().add(new LoTest(2));
    }

    public void method2() {
        List<LoTest> loTests = deadShuiQiuThreadLocal.get();
        System.out.println(loTests);
    }
}

class LoTest {
    private int a;

    public LoTest(int a) {
        this.a = a;
    }

    @Override
    public String toString() {
        return "LoTest{" +
                "a=" + a +
                '}';
    }
}
